<?php
/**
 * Helper to generate a popup box
 *
 * PHP versions 4 and 5
 *
 * TutoriumBase (http://tutoriumbase.my-reality.de)
 * Copyright 2012, Miguel Gonzalez (http://my-reality.de)
 *
 *
 * @copyright     Copyright 2012, Miguel Gonzalez (http://my-reality.de)
 * @link          http://tutoriumbase.my-reality.de TutoriumBase
 * @since         TutoriumBase v 0.1
 */

class PopupHelper extends AppHelper {
    
    
    /**
     * Register an object with jQuery
     * 
     * @author      Miguel Gonzalez
     * @since       TutoriumBase v 0.1
     */
    function registerHoverObject($content, $html, $obj_id) {
        $content = '<script type="text/javascript">
                         javascript:setPopupContent("' . $content . '", "' . $html . '", "' . $obj_id . '");                         
                    </script>';
        
        return $content;
    }
    
    
    
    
    
    /**
     * Generate a fully animated popup box
     * 
     * @author      Miguel Gonzalez
     * @since       TutoriumBase v 0.1
     */
    function generate($id, $text, $ontop = 1) {
        $html = '';
        if ($ontop) {
            $html = "<div id='popup' class='popup_" . $id . "'><div id='top'>" . $ontop . "</div><div id='pop_content'></div><div id='pop_arrow_down'></div></div>";  
        } else {
            $html = "<div id='popup' class='popup_" . $id . "'><div id='top'>" . $ontop . "</div><div id='pop_arrow_up'></div><div id='pop_content'></div></div>";  
        }
        $content = $this->registerHoverObject($text, $html, $id);
        
        return $content;
    }
    
} ?>
